import { ActivatedRoute } from '@angular/router'
import { Component, OnInit } from '@angular/core';
import { StorageService } from 'src/app/cache/storage.service';

@Component({
  selector: 'app-show-code',
  templateUrl: './show-code.component.html',
  styleUrls: ['./show-code.component.less']
})
export class ShowCodeComponent implements OnInit {

  /**
   * 根据ddl自动生成代码接口数据详情
   */
  autoCode:any={};
  /**
   * 实体类，dao类，service类等
   */
  javaCode:any={};
  /**
   * true 表示加载初始信息，需要使用表格
   */
  javaCodeInfo:boolean=false;
  /**
   *  javaCodeInfo Data
   */
  data:Array<any>=[];

  constructor(
    public route:ActivatedRoute,
    public storage:StorageService) {
     
  }

  ngOnInit(): void {
    this.javaCodeInfo=false;
    this.autoCode = this.storage.get("autoCode");
    this.data = this.autoCode.fieldList;
    // JS路由：动态路由
    this.route.queryParams.subscribe((data:any) => {
      this.javaCode=this.autoCode.resultByParams[data.jCodeInit];
    });
  }

  getResultByParams(params:any) {
    if(params == "info"){
      this.javaCodeInfo=true;
    }else{
      this.javaCodeInfo=false;
    }
    this.javaCode=this.autoCode.resultByParams[params];
    // console.log(this.javaCode);
  }

  

}
